home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_09
/
1109110a
< prev
next >
Wrap
Text File
|
1993-07-11
|
650b
|
31 lines
/* array1.c: Uses an array name as a pointer */
/* NOTE: Pointers and ints are 2-bytes in all examples */
#include <stdio.h>
main()
{
int a[] = {0,1,2,3,4};
int *p = a;
printf("sizeof a == %d\n",sizeof a);
printf("sizeof p == %d\n",sizeof p);
printf("p == %p, &a[0] == %p\n",p,&a[0]);
printf("*p == %d, a[0] == %d\n",*p,a[0]);
p = a + 2;
printf("p == %p, &a[2] == %p\n",p,&a[2]);
printf("*p == %d, a[2] == %d\n",*p,a[2]);
return 0;
}
/* OUTPUT
sizeof a == 10
sizeof p == 2
p == FFEC, &a[0] == FFEC
*p == 0, a[0] == 0
p == FFF0, &a[2] == FFF0
*p == 2, a[2] == 2
*/